<template>
  <div>
    <div class="top">
      <h2>全部订单</h2>
      <el-select v-model="value" placeholder="Select" size="large" style="width: 150px" class="selected" @change="getList">
        <el-option label="全部" value="0"/>
        <el-option label="飞机票" value="1"/>
        <el-option label="火车票" value="4"/>
        <el-option label="汽车票" value="5"/>
        <el-option label="景点" value="2"/>
        <el-option label="酒店" value="3"/>
      </el-select>
    </div>
    <ul class="list">
      <li>产品信息</li>
      <li>订单金额</li>
      <li>订单编号</li>
      <li>订单状态</li>
      <li>订单操作</li>
    </ul>
    <div>
      <div  v-for="item in tableData" :key="item.id">
        <div class="item" v-if="item.classification==1">
          <div class="item_div1"><img src="https://file.40017.cn/appresource/image/pc/order/img_jp.jpg" alt=""></div>
          <div class="item_div2">
            <div class="title">{{item.orderName}}</div>
            <div class="content">{{item.startTime}}至{{item.endTime}}</div>
          </div>
          <div class="item_div3">￥{{item.price}}</div>
          <div class="item_div4">{{item.orderNumber}}</div>
          <div class="item_div5">{{item.status==1?'待付款':'已付款'}}</div>
          <div class="item_div6">
            <el-button v-if="item.status==1" type="success"><a style="text-decoration: none;color: #fff" :href="`http://localhost:8080/alipay/pay?subject=${item.orderName}&traceNo=${item.orderNumber}&totalAmount=${item.price}`">去支付</a></el-button>
            <el-button v-else type="success">已支付</el-button>
          </div>
        </div>
        <div class="item" v-if="item.classification==2">
          <div class="item_div1"><img src="https://img1.40017.cn/cn/c/order/s/2015/orderlist/img_jd.jpg" alt=""></div>
          <div class="item_div2">
            <div class="title">{{item.orderName}}</div>
            <div class="content">游玩日期：{{new Date().getFullYear()}}-{{new Date().getMonth()+1}}-{{new Date().getDate()+1}}</div>
            <div class="content">门票数量：1张</div>
          </div>
          <div class="item_div3">￥{{item.price}}</div>
          <div class="item_div4">{{item.orderNumber}}</div>
          <div class="item_div5">{{item.status==1?'待付款':'已付款'}}</div>
          <div class="item_div6">
            <el-button v-if="item.status==1" type="success"><a style="text-decoration: none;color: #fff" :href="`http://localhost:8080/alipay/pay?subject=${item.orderName}&traceNo=${item.orderNumber}&totalAmount=${item.price}`">去支付</a></el-button>
            <el-button v-else type="success">已支付</el-button>
          </div>
        </div>
        <div class="item" v-if="item.classification==3">
          <div class="item_div1"><img src="https://img1.40017.cn/cn/c/order/s/2015/orderlist/img_hotel.jpg" alt=""></div>
          <div class="item_div2">
            <div class="title">{{item.orderName}}</div>
            <div class="content">入住时间：{{item.startTime}}</div>
            <div class="content">离店时间：{{item.endTime}}</div>
          </div>
          <div class="item_div3">￥{{item.price}}</div>
          <div class="item_div4">{{item.orderNumber}}</div>
          <div class="item_div5">{{item.status==1?'待付款':'已付款'}}</div>
          <div class="item_div6">
            <el-button v-if="item.status==1" type="success"><a style="text-decoration: none;color: #fff" :href="`http://localhost:8080/alipay/pay?subject=${item.orderName}&traceNo=${item.orderNumber}&totalAmount=${item.price}`">去支付</a></el-button>
            <el-button v-else type="success">已支付</el-button>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { useCounterStore } from '@/stores/counter';
import {onMounted, ref} from 'vue';
import type { TabsPaneContext } from 'element-plus';
import {showOrderList} from "@/api/plane.js"

const value=ref("0")

const activeName = ref('first');

const handleClick = (tab: TabsPaneContext, event: Event) => {
  console.log(tab, event);
};
const tableData = ref([])

const getList=async ()=>{
  const res=await showOrderList(value.value)
  console.log(res)
  tableData.value=res.data.data
}
getList()
</script>

<style scoped>
.top{
  display: flex;
  border-bottom: 1px solid rgba(0,0,0,.1);
  padding-bottom: 12px;
  h2{
    font-size: 28px;
    font-weight: 400;
    line-height:28px;
    padding: 15px 10px 0 10px;
  }
  .selected{
    margin-left: 20px;
    padding-top: 12px;
  }
}
.list{
   display: flex;
   border-bottom: 1px solid rgba(0,0,0,.1);
   li{
     font-size: 14px;
     color: #999;
     line-height: 22px;
     padding: 8px 0;
     text-align: center;
   }
   li:nth-of-type(1){
     width: 325px;
   }
   li:nth-of-type(2){
     width: 180px;
     margin-left: 32px;
   }
   li:nth-of-type(3){
     width: 190px;
   }
   li:nth-of-type(4){
     margin-left: 10px;
     width: 102px;
   }
   li:nth-of-type(5){
     width: 120px;
   }
 }
.item{
  margin-top: 15px;
  display: flex;
  text-align: center;
  .item_div1{
    width: 115px;
    height: 90px;
  }
  .item_div2{
    width: 215px;
    margin-left: 12px;
    line-height: 22px;
    text-align: left;
    .title{
      font-weight: 700;
      color: #333;
      font-size: 14px;
      margin-bottom: 3px;
      line-height: 22px;
    }
    .content{
      font-size: 12px;
      color: #666;
      line-height: 20px;
    }
  }
  .item_div3{
    font-weight: 700;
    width: 180px;
    margin-left: 14px;
    color:#ff6257;
  }
  .item_div4{
    width: 190px;
    color: #333;
    line-height: 22px;
  }
  .item_div5{
    line-height: 22px;
    width: 100px;
    margin-left: 13px;
  }
  .item_div6{
    margin-left: 22px;
  }

}
</style>